forked from
quillmatiq.com/augment
Fork of Chiri for Astro for my blog
1import { getCollection } from 'astro:content'
2import { OGImageRoute } from 'astro-og-canvas'
3import { themeConfig } from '../../config'
4
5const collectionEntries = await getCollection('posts')
6
7// Map the array of content collection entries to create an object.
8// Converts [{ id: 'post.md', data: { title: 'Example', pubDate: Date } }]
9// to { 'post.md': { title: 'Example', pubDate: Date } }
10const pages = Object.fromEntries(
11 collectionEntries.map(({ id, data }) => [id.replace(/\.(md|mdx)$/, ''), data])
12)
13
14export const { getStaticPaths, GET } = OGImageRoute({
15 param: 'route',
16 pages,
17 getImageOptions: (_path, page) => ({
18 title: page.title,
19 description: themeConfig.site.title,
20 logo: {
21 path: 'public/og/og-logo.png',
22 size: [80, 80]
23 },
24 bgGradient: [[255, 255, 255]],
25 bgImage: {
26 path: 'public/og/og-bg.png',
27 fit: 'fill'
28 },
29 padding: 64,
30 font: {
31 title: {
32 color: [28, 28, 28],
33 size: 68,
34 weight: 'SemiBold',
35 families: ['PingFang SC']
36 },
37 description: {
38 color: [180, 180, 180],
39 size: 40,
40 weight: 'Medium',
41 families: ['PingFang SC']
42 }
43 },
44 fonts: [
45 'https://cdn.jsdelivr.net/npm/font-pingfang-sc-font-weight-improved@latest/PingFangSC-Medium.woff2',
46 'https://cdn.jsdelivr.net/npm/font-pingfang-sc-font-weight-improved@latest/PingFangSC-Semibold.woff2',
47 ]
48 })
49})